package com.bing.dao;

import com.bing.bean.sys.SysUser;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * Created by Administrator on 2015/6/13.
 */
@Repository

public interface SysUserDao {

    @Insert("insert into SysUser(accountId,username,name,password,salt,phone) values(#{user.accountId},#{user.username}," +
            " #{user.password},#{user.salt},#{user.phone})")
    int createSysUser(SysUser user);


    @Select("select * from SysUser where username=#{name}")
    @Results(
            @Result(property = "sysRoles", column = "id", many = @Many(select = "com.bing.dao.SysRoleDao.findRolesByUserId"))
    )
    SysUser findByName(String name);

}
